from collections import OrderedDict


class quanzhong:
    def __init__(self,a,b,k):
        self.a=a;
        self.b=b;
        self.k=k;
    def judge(self,i):
        count=0;
        while True:
            if (i % 2 == 0):
                i = i / 2;
            elif (i % 2 == 1):
                i = 3 * i + 1;
            count=count+1;
            if(i==1):
                break;
        return count;
    def solution(self):
        num=[];
        dict={};
        for i in range(self.a,self.b+1):
            dict[i]=int(self.judge(i));
        dict2=sorted(dict.items(),key=lambda x:x[1]);
        dict3=OrderedDict(dict2);
        for i in dict3.keys():
            num.append(i);
        print(num[self.k-1]);

if __name__ == '__main__':
    a=int(input("a="));
    b=int(input("b="));
    k=int(input("k="));
    c=quanzhong(a,b,k);
    c.solution();








